package com.example.campuslink.commen.db.ai

import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverters
import com.example.campuslink.commen.db.DeepSeekTalkBeanConverter


@Database(entities = [AiTable::class], version = 1, exportSchema = true)
@TypeConverters(DeepSeekTalkBeanConverter::class)
abstract class AiDataBase() : RoomDatabase() {
    abstract fun aiDao(): AiDao

    companion object {
        @Volatile
        private var INSTANCE: AiDataBase? = null

        fun getDatabase(context: Context): AiDataBase {
            return INSTANCE ?: synchronized(this) {
                val instance = Room.databaseBuilder(
                    context.applicationContext,
                    AiDataBase::class.java,
                    "ai_talk_dataBase"
                ).build()
                INSTANCE = instance
                instance
            }
        }
    }
}
